package org.cloudie.docs.editor.client.widgets;

import org.cloudie.docs.editor.client.resources.icons.IconsHelper;

import com.google.gwt.user.client.ui.AbstractImagePrototype;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.HasVerticalAlignment;
import com.google.gwt.user.client.ui.HorizontalPanel;
import com.google.gwt.user.client.ui.Image;
import com.google.gwt.user.client.ui.PushButton;
import com.google.gwt.user.client.ui.TextBox;

public class SearchBox extends Composite {

  protected HorizontalPanel panel;
  protected TextBox box;
  protected PushButton button;
  
  public SearchBox(AbstractImagePrototype icon) {
	panel = new HorizontalPanel();
	panel.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE);
	panel.setStylePrimaryName("cloudie-searchbox");
	box = new TextBox();
	box.setStylePrimaryName("cloudie-searchbox-field");
	button = new PushButton(IconsHelper.icons.SearchButton().createImage());
	button.setStylePrimaryName("cloudie-searchbox-button");
	Image iconImg = icon.createImage();
	iconImg.setTitle("Search using Google");
	iconImg.setStylePrimaryName("cloudie-searchbox-icon");
	panel.add(iconImg);
	panel.add(box);
	panel.add(button);
	initWidget(panel);
  }
  
  public PushButton getButton() {
	return button;
  }
  
  public TextBox getTextBox() {
	return box;
  }
  
  @Override
  public void setWidth(String w) {
	box.setWidth(w);
  }
  
}
